package com.fl.anno3d.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fl.anno3d.entity.Proince;
import com.fl.anno3d.mapper.ProinceMapper;
import com.fl.anno3d.param.MvtParam;
import com.fl.anno3d.param.PropertyParam;
import com.fl.anno3d.param.RecTangleParam;
import com.fl.anno3d.param.ZoomLevelParam;
import com.fl.anno3d.service.ProinceService;
import com.fl.anno3d.util.WktUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author 18210
* @description 针对表【proince】的数据库操作Service实现
* @createDate 2023-04-07 17:20:01
*/
@Service
public class ProinceServiceImpl extends ServiceImpl<ProinceMapper, Proince> implements ProinceService {

    @Autowired
    private ProinceMapper proinceMapper;

    @Override
    public Byte[] getMvtData(MvtParam param){
        Map<String, Object> map = BeanUtil.beanToMap(param);
        Byte[]  mvtData = (Byte[]) proinceMapper.getMvtData(map);
        return mvtData;
    }

    @Override
    public List<String> getPOIJson(String table, ZoomLevelParam zoomParam, RecTangleParam recParam, PropertyParam propertyParam) {
        Map<String, Object> map = new HashMap<>();
        map.put("table",table);
        map.put("cityLevel",zoomParam.getZoomLevel());
        map.put("column",propertyParam.getColumn());
        map.put("levelColumn",zoomParam.getLevelField());
        //POLYGON((118.95812615861949 25.850830078125,118.95812615861949 26.422119140625,119.63858061101618 26.422119140625,119.63858061101618 25.850830078125,118.95812615861949 25.850830078125))
        String wkt = WktUtil.buildPolygon(recParam.getLeftDownX(),recParam.getLeftDownY(),recParam.getRightUpX(),recParam.getRightUpY());
        map.put("wkt",wkt);
        List<String> result = proinceMapper.getPOIJson(map);
        return result;
    }
}




